package de.hhkk.view.stammdaten;

import org.eclipse.nebula.widgets.calendarcombo.CalendarCombo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;

import de.hhkk.controller.NavigationController;

public class UIPersonenstammdatenNeu extends Composite
{
    private Text      txtPersonennr;
    private Text      text_1;
    private Text      txtPersonengr;
    private Text      txtVorname;
    private Text      txtName;
    private Text      txtStrasse;
    private Text      txtEmail;
    private Text      txtTel;
    private Text      txtLand;
    private Text      txtGrundkenntnisse;
    private Text      txtOrt;
    private Text      txtPLZ;
    private Text      txtIBAN;
    private Text      txtMobil;
    private Text      txtHonorar;
    private Text      txtStunden;
    public static int vhonorar   = 0;
    public static int vland      = 0;
    public static int vstunden   = 0;
    public static int veintrittd = 0;
    public static int vgrundk    = 0;

    /**
     * Create the composite.
     * @param parent
     * @param style
     */
    public UIPersonenstammdatenNeu(Composite parent, int style, String title)
    {
        super(parent, style);
        setLayout(new FillLayout(SWT.HORIZONTAL));

        TabFolder tabFolder = new TabFolder(this, SWT.NONE);
        tabFolder.setBounds(0, 0, 122, 43);

        TabItem tbtmNewItem = new TabItem(tabFolder, SWT.NONE);
        tbtmNewItem.setText(title);

        Composite composite = new Composite(tabFolder, SWT.NONE);
        tbtmNewItem.setControl(composite);
        composite.setLayout(new GridLayout(1, false));

        Group group = new Group(composite, SWT.NONE);
        GridData gd_group = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
        gd_group.heightHint = 172;
        gd_group.widthHint = 660;
        group.setLayoutData(gd_group);
        group.setText("Suchkriterien");
        group.setBounds(0, 0, 650, 227);
        group.setLayout(new GridLayout(8, false));

        Label lblPersonennr = new Label(group, SWT.NONE);
        lblPersonennr.setText("Personen-Nr.");

        txtPersonennr = new Text(group, SWT.BORDER);
        GridData gd_txtPersonennr = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1);
        gd_txtPersonennr.widthHint = 140;
        txtPersonennr.setLayoutData(gd_txtPersonennr);
        // Nur Zahlen erlauben
        txtPersonennr.addListener(SWT.Verify, new Listener()
        {
            @Override
            public void handleEvent(Event e)
            {
                String string = e.text;
                char[] chars = new char[string.length()];
                string.getChars(0, chars.length, chars, 0);
                for (int i = 0; i < chars.length; i++)
                {
                    if (!('0' <= chars[i] && chars[i] <= '9'))
                    {
                        e.doit = false;
                        return;
                    }
                }
            }
        });
        Label lblNewLabel_2 = new Label(group, SWT.NONE);
        lblNewLabel_2.setText("Stra\u00DFe");

        txtStrasse = new Text(group, SWT.BORDER);
        txtStrasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblNewLabel_5 = new Label(group, SWT.NONE);
        lblNewLabel_5.setText("Land");

        txtLand = new Text(group, SWT.BORDER);
        if (vland == 1)
        {
            txtLand.setEnabled(false);
        }
        txtLand.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label label_1 = new Label(group, SWT.SEPARATOR);
        label_1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 7));
        new Label(group, SWT.NONE);

        Label lblPersonengr = new Label(group, SWT.NONE);
        lblPersonengr.setText("Personen-Gr.");

        txtPersonengr = new Text(group, SWT.BORDER);
        txtPersonengr.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblOrt = new Label(group, SWT.NONE);
        lblOrt.setText("Ort");

        txtOrt = new Text(group, SWT.BORDER);
        txtOrt.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

        Label lblNewLabel_6 = new Label(group, SWT.NONE);
        lblNewLabel_6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblNewLabel_6.setText("Grundkenntnisse");

        txtGrundkenntnisse = new Text(group, SWT.BORDER);
        if (vgrundk == 1)
        {
            txtGrundkenntnisse.setEnabled(false);
        }
        txtGrundkenntnisse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        new Label(group, SWT.NONE);

        Label lblBezeichnung = new Label(group, SWT.NONE);
        lblBezeichnung.setText("Anrede");

        text_1 = new Text(group, SWT.BORDER);
        text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblPlz = new Label(group, SWT.NONE);
        lblPlz.setText("PLZ");

        txtPLZ = new Text(group, SWT.BORDER);
        txtPLZ.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

        Label lblNewLabel_7 = new Label(group, SWT.NONE);
        lblNewLabel_7.setText("Geburtsdatum");

        CalendarCombo calendarCombo = new CalendarCombo(group, SWT.NONE);

        Button button = new Button(group, SWT.NONE);
        button.setText("Suchen");

        Label lblNewLabel = new Label(group, SWT.NONE);
        lblNewLabel.setText("Vorname");

        txtVorname = new Text(group, SWT.BORDER);
        txtVorname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblNewLabel_3 = new Label(group, SWT.NONE);
        lblNewLabel_3.setText("E-Mail");

        txtEmail = new Text(group, SWT.BORDER);
        txtEmail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblNewLabel_8 = new Label(group, SWT.NONE);
        lblNewLabel_8.setText("Eintrittsdatum");

        CalendarCombo calendarCombo_1 = new CalendarCombo(group, SWT.NONE);
        if (veintrittd == 1)
        {
            calendarCombo_1.setEnabled(false);
        }

        new Label(group, SWT.NONE);

        Label lblNewLabel_1 = new Label(group, SWT.NONE);
        lblNewLabel_1.setText("Name");

        txtName = new Text(group, SWT.BORDER);
        txtName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblNewLabel_4 = new Label(group, SWT.NONE);
        lblNewLabel_4.setText("Tel.");

        txtTel = new Text(group, SWT.BORDER);
        txtTel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblNewLabel_9 = new Label(group, SWT.NONE);
        lblNewLabel_9.setText("IBAN");

        txtIBAN = new Text(group, SWT.BORDER);
        txtIBAN.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        new Label(group, SWT.NONE);

        Label lblNewLabel_10 = new Label(group, SWT.NONE);
        lblNewLabel_10.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true, 1, 1));
        lblNewLabel_10.setText("Mobil");

        txtMobil = new Text(group, SWT.BORDER);
        txtMobil.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblNewLabel_11 = new Label(group, SWT.NONE);
        lblNewLabel_11.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        lblNewLabel_11.setText("Honorar");

        txtHonorar = new Text(group, SWT.BORDER);

        if (vhonorar == 1)
        {
            txtHonorar.setEnabled(false);
        }
        txtHonorar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

        Label lblStunden = new Label(group, SWT.NONE);
        lblStunden.setText("Stunden");

        txtStunden = new Text(group, SWT.BORDER);
        if (vstunden == 1)
        {
            txtStunden.setEnabled(false);
        }
        txtStunden.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        new Label(group, SWT.NONE);

        Label label_8 = new Label(group, SWT.NONE);
        label_8.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));

        Label label_9 = new Label(group, SWT.NONE);
        GridData gd_label_9 = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
        gd_label_9.widthHint = 69;
        label_9.setLayoutData(gd_label_9);
        Label label_3 = new Label(group, SWT.NONE);
        label_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
        Label label_6 = new Label(group, SWT.NONE);
        label_6.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);
        new Label(group, SWT.NONE);

        Composite composite_1 = new Composite(composite, SWT.NONE);
        GridData gd_composite_1 = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
        gd_composite_1.widthHint = 164;
        composite_1.setLayoutData(gd_composite_1);
        composite_1.setBounds(0, 0, 157, 35);
        composite_1.setLayout(new GridLayout(2, false));

        Button btnSpeichern = new Button(composite_1, SWT.NONE);
        btnSpeichern.setText("Speichern");

        Button btnSchliessen = new Button(composite_1, SWT.NONE);
        btnSchliessen.addSelectionListener(new SelectionAdapter()
        {
            @Override
            public void widgetSelected(SelectionEvent e)
            {
                NavigationController.getInstance().clear();
                dispose();
            }
        });
        btnSchliessen.setText("Schlie\u00DFen");

    }

    @Override
    protected void checkSubclass()
    {
        // Disable the check that prevents subclassing of SWT components
    }
}
